<script setup lang="ts">
import { Cell } from '@antv/x6'
import { ImagePicker } from '@yk/components/draw/shapes/components/image-picker'
import { ObjectUtil } from '@utils/object-util'

const props = defineProps<{
  cell: Cell | any
}>()

let _cell = toRaw(props.cell)

watch(() => props.cell, () => {
  _cell = toRaw(props.cell)
  init()
})

onMounted(() => {
  init()
})

function init () {
  saveForm.value = ObjectUtil.copy(props.cell.data.dataConfig.dataOption)
}

// region TODO 表单
const saveForm = ref<any>({})
// endregion

// region TODO 当前报警统计
function alarmStatisticsSubmit () {
  if (ObjectUtil.isNotEmpty(saveForm.value.dataRange)) {
    _cell.data.dataConfig.dataOption = saveForm.value
    ElMessage.success('已绑定')
  } else {
    ElMessage.info('请选择数据范围')
  }
}
// endregion

</script>

<template>
  <el-collapse-item title="数据类型" name="DataType">
    <el-form-item label="展示数据">
      <el-select v-model="saveForm.dataType">
        <el-option value="alarmStatistics" label="报警统计" />
      </el-select>
    </el-form-item>
    <el-form-item label="数据范围">
      <div class="d-flex">
        <span>近</span>
        <el-input-number
          v-model="saveForm.dataRange"
          class="mx-2" :min="1" :max="31"
          :step="1"
          style="width: 100px;"
        />
        <span>天</span>
      </div>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" class="mt-2" @click="alarmStatisticsSubmit">确定</el-button>
    </el-form-item>
  </el-collapse-item>
</template>

<style scoped lang="scss">
</style>
